
#ifndef FASTSERVERLAPPLICATION_H
#define FASTSERVERLAPPLICATION_H

#include "FASTApplication.h"

#include <boost/asio.hpp>

#include <Codecs\Encoder_fwd.h>
#include <Codecs\DataDestination_fwd.h>
#include <Messages\FieldSet_fwd.h>

#include <string>

typedef boost::shared_ptr< boost::asio::ip::tcp::socket> socket_ptr;

    class FASTServerApplication : public FASTApplication
    {
    public:
      FASTServerApplication();
      ~FASTServerApplication();

      virtual bool init(int argc, char * argv[]);

	  /// @brief run the program
      /// @returns a value to be used as an exit code of the program (0 means all is well)
      virtual int run();

    private:
		void Session(socket_ptr sock);
		void Server(boost::asio::io_service& io_service, short port);

		void SendDataForMode(socket_ptr sock);
		void SendTestFASTMessages(socket_ptr sock, unsigned int blockNumbers, unsigned int messagesPerBlock);
		void FASTServerApplication::EncodeTestMessage(QuickFAST::Codecs::DataDestination& destination, unsigned int blockNumber, unsigned int messagesNumber);

		static void AddField(QuickFAST::Messages::FieldSet& message,
                                  const char* fieldName,
                                  const std::string& fieldValue);

	private:
		QuickFAST::Codecs::EncoderPtr pEncoder_;
    };

#endif // FASTSERVERLAPPLICATION_H